#!/usr/bin/tcsh

umask 000



foreach h ( `seq 1 5` )
# rm -f dataforR/holdout${h}_testpred_names.txt
# l1 holdout$h/testpred/ > dataforR/H${h}.testpred.names.txt
cd holdout$h

# foreach setnum ( `ls -1 data/H*.train.*`)
# set setnum = $setnum:e
# 
# rm -f eval/syn_sp.$setnum
# rm -f eval/syn_bl.$setnum

# foreach syn ( `ls -1 syn/*dat$setnum*.sp.*` )
# echo $syn >> eval/syn_sp.$setnum
# end
# 
# foreach syn ( `ls -1 syn/*dat$setnum*.bl.*` )
# echo $syn >> eval/syn_bl.$setnum
# end
# 
# nnforward eval/syn_sp.$setnum data/test_sp.$setnum | grep -v "^#" > eval/ensamble_test_pred_sp.$setnum
# nnforward eval/syn_bl.$setnum data/test_bl.$setnum | grep -v "^#" > eval/ensamble_test_pred_bl.$setnum

# end

rm -f eval/H${h}.syn_sp
rm -f eval/H${h}.syn_bl
rm -f eval/H${h}.singleEvals
rm -f ../dataforR/H${h}.eval.names.txt

foreach syn ( `ls -1 syn/*.sp.*` )
echo $syn >> eval/H${h}.syn_sp
set id = `perl -e '$n = $ARGV[0]; $n =~ s/^syn_//; print $n' ${syn:t:r}`
echo $id `nnforward -s $syn data/H${h}.eval_sp | grep -v "^#" | awk '{print $1, $3}'` >> eval/H${h}.singleEvals
echo $id >> ../dataforR/H${h}.eval.names.txt
end

foreach syn ( `ls -1 syn/*.bl.*` )
echo $syn >> eval/H${h}.syn_bl
set id = `perl -e '$n = $ARGV[0]; $n =~ s/^syn_//; print $n' ${syn:t:r}`
echo $id `nnforward -s $syn data/H${h}.eval_bl | grep -v "^#" | awk '{print $1, $3}'` >> eval/H${h}.singleEvals
echo $id >> ../dataforR/H${h}.eval.names.txt
end

nnforward eval/H${h}.syn_sp data/H${h}.eval_sp | grep -v "^#" > eval/H${h}.ensamble_eval_pred_sp
nnforward eval/H${h}.syn_bl data/H${h}.eval_bl | grep -v "^#" > eval/H${h}.ensamble_eval_pred_bl
cd ..

rm -f dataforR/H${h}.testpredcorr
foreach f (`ls -1 holdout${h}/testpred/*`)
set id = `perl -e '$n = $ARGV[0]; $n =~ s/^tePred_//; print $n' ${f:t:r}`
echo $id `cat $f | gawk '{print $3, $5}' | xycorr | gawk '{print $7}'` >> dataforR/H${h}.testpredcorr
end


end

